﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using dreamwork.pay.api.Services;
using Microsoft.AspNetCore.Mvc;

namespace dreamwork.pay.api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
		private readonly IPayServices _payService;

		public UserController(IPayServices payService)
		{
			_payService = payService;
		}

		[HttpPost, Route("[action]")]
		public async Task<IActionResult> AddUserAsync()
		{
			await _payService.AddUserAsync();
			return Ok("OK");
		}
		[HttpGet, Route("[action]")]
		public async Task<IActionResult> GetUserAsync()
		{
			var item = await _payService.GetUserAsync();
			return Ok(item);
		}
		[HttpPut, Route("[action]")]
		public async Task<IActionResult> UpdateUserAsync()
		{
			var item = await _payService.GetUserAsync();
			item.Name = DateTime.Now.ToString();
			await _payService.UpdateUserAsync(item);
			return Ok(item);
		}
	}
}
